package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@Setter
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor

public class TravelCommend extends BaseDomain{

    public static final Integer TYPE_WEEK = 1; //每周
    public static final Integer TYPE_MONTH = 2; //每月
    public static final Integer TYPE_STRATEGY = 3; //攻略


    //游记
    private Long travelId;

    private String title;

    private String subTitle;

    private String coverUrl;
    //推荐时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type=TYPE_WEEK;


    //列表显示数据
    public String getTypeName() {
        String str="每周推荐";
        if (type==TYPE_MONTH) {
            return str="每月推荐";
        }else if (type==TYPE_STRATEGY) {
            return str="攻略推荐";
        }
        return str;
    }

    //推荐回显json字符串
    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type", type);
        map.put("travelId", travelId);
        return JSONUtil.toJSONString(map);
    }


}